package pers.ervinse.shoppingmall.viewmodel;

import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;

public class UserViewModel extends ViewModel {

    private MutableLiveData<Boolean> isLoggedIn = new MutableLiveData<>(false);
    private MutableLiveData<String> userToken = new MutableLiveData<>();
    private MutableLiveData<String> avatarUrl = new MutableLiveData<>();
    private MutableLiveData<String> userName = new MutableLiveData<>();
    private MutableLiveData<String> gender = new MutableLiveData<>();

    public MutableLiveData<Boolean> getIsLoggedIn() {
        return isLoggedIn;
    }

    public void setIsLoggedIn(Boolean isLoggedIn) {
        this.isLoggedIn.setValue(isLoggedIn);
    }

    public MutableLiveData<String> getUserToken() {
        return userToken;
    }

    public void setUserToken(String userToken) {
        this.userToken.setValue(userToken);
    }

    public MutableLiveData<String> getAvatarUrl() {
        return avatarUrl;
    }

    public void setAvatarUrl(String avatarUrl) {
        this.avatarUrl.setValue(avatarUrl);
    }

    public MutableLiveData<String> getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName.setValue(userName);
    }

    public MutableLiveData<String> getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender.setValue(gender);
    }

    // 清除用户数据
    public void clearUserData() {
        setIsLoggedIn(false);
        setUserToken(null);
        setAvatarUrl(null);
        setUserName(null);
        setGender(null);
    }
}
